from django.db import models
from django.contrib.auth.models import User
from datetime import datetime

class AgbayUsers(models.Model):
	Name = models.CharField(max_length=45)
	Email = models.CharField(max_length=45)
	Password = models.CharField(max_length=45)
	CreatedAt= models.DateTimeField('Created at')
	UpdatedAt = models.DateTimeField('Updated at')
	

class Items(models.Model):
	SellerUserId = models.ForeignKey(AgbayUsers, related_name='SellerUserId', null = True)
	BuyerUserId = models.ForeignKey(AgbayUsers, related_name='BuyerUserId', null = True)
	MinBid = models.FloatField()
	MaxBid = models.FloatField()
	CurBid = models.FloatField()
	BuyPrice = models.FloatField()
	IsCompleted = models.BooleanField()
	CreatedAt = models.DateTimeField('Created at')
	UpdatedAt = models.DateTimeField('Updated at')
	EndingAt = models.DateTimeField('Ends at')
	
class Bids(models.Model):
	UserId = models.ForeignKey(AgbayUsers, related_name='UserId', null = True)
	ItemId = models.ForeignKey(Items, related_name='ItemId', null = True)
	Amount = models.FloatField()
	CreatedAt = models.DateTimeField('Created at')
	UpdatedAt = models.DateTimeField('Updated at')
	
class Ratings(models.Model):
	RateeUserId = models.ForeignKey(AgbayUsers, related_name='RateeUserId', null = True)
	RaterUserId = models.ForeignKey(AgbayUsers, related_name='RaterUserId', null = True)
	Rating = models.PositiveIntegerField(null=True)
	Reason = models.CharField(max_length=500, null=True)
	IsReport = models.BooleanField()
	CreatedAt = models.DateTimeField('Created at')
	UpdatedAt = models.DateTimeField('Updated at')
	
class Notifications(models.Model):
	RelatedRatingOrItemId = models.IntegerField()
	Type = models.PositiveIntegerField()
	Viewed = models.BooleanField()
	CreatedAt = models.DateTimeField('Created at')